<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm" :model="formInline" class="demo-form-inline">
          <el-form-item label="提交时间" prop="time">
            <el-date-picker
              v-model="formInline.time"
              type="datetimerange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              :default-time="['00:00:00', '23:59:59']"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd HH:mm:ss"
              :picker-options="pickerDayStep">
            </el-date-picker>
          </el-form-item>
      <el-form-item label="申请人" prop="creator">
        <el-select v-model="formInline.creator" placeholder="请选择提交人">
           <el-option
            :label="'全部'"
            :key="consts.ALL"
            :value="undefined"
          ></el-option>
          <el-option
            v-for="(item,index) in auditApplyList"
            :label="item"
            :key="index"
            :value="item"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="审核人" prop="approver">
        <el-select v-model="formInline.approver" placeholder="请选择审核人">
           <el-option
            :label="'全部'"
            :key="consts.ALL"
            :value="undefined"
          ></el-option>
          <el-option
            v-for="(item,index) in auditManagerList"
            :label="item"
            :key="index"
            :value="item"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item prop="orderId" label="提现单号">
        <el-input v-model="formInline.orderId" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="formInline.status" placeholder="请选择审核状态">
          <el-option
            v-for="item in consts.REORDER_AUDIT_STATUS"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="出款类型" prop="dealType">
        <el-select v-model="formInline.withdrawType" placeholder="请选择出款类型">
          <el-option
            :label="'全部'"
            :key="consts.ALL"
            :value="undefined"
          ></el-option>
          <el-option
            v-for="item in consts.OUT_TYPE_PAY"
            :label="item.title"
            :key="item.value"
            :value="item.value"
            v-if="dataRoleCheck(dataPermissionObj[item.value])"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="操作类型" prop="type">
        <el-select v-model="formInline.type" placeholder="请选择操作类型">
          <el-option
            v-for="item in consts.WITHDRAW_TYPE"
            :label="item.title"
            :key="item.value"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item prop="username" label="账户名">
          <el-input v-model="formInline.username" placeholder="请输入" @keyup.enter.native="$emit('on-filter',formInline)"></el-input>
      </el-form-item>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="$emit('on-filter',formInline)">搜索
      </el-button>
      <el-button @click="selfResetForm('ruleForm')">重置</el-button>
    </el-form>
  </div>

</template>

<script>
import { getWithdrawReturnApprover, getWithdrawReturnCreator } from '@/services/api/withdraw';
import { form, pickerOption } from '@/build';

export default {
  name: 'audit-filter',
  mixins: [form, pickerOption],
  data() {
    return {
      auditApplyList: [],
      auditManagerList: [],
      formInline: {
        type: 1,
        time: [moment().format('YYYY-MM-DD 00:00:00'), moment().format('YYYY-MM-DD 23:59:59')],
        approver: undefined,
        creator: undefined,
        withdrawType: undefined,
        username: undefined,
        status: consts.ALL,
        orderId: undefined,
      },
      dataPermissionObj: {
        // 0: 'manualWithdraw',
        1: 'thirdAutoWithdraw',
        2: 'thirdManualWithdraw',
      },

    };
  },
  methods: {
    selfResetForm(formName) {
      this.resetForm(formName);
      this.$parent.getAll();
    },
  },
  mounted() {
    this.bindGet(getWithdrawReturnCreator, 'auditApplyList', { });
    this.bindGet(getWithdrawReturnApprover, 'auditManagerList', { });
    // this.bindGet(getUserLevelList, 'levelList',{
    //   action: 'getLevel'
    // });
    // this.doAction({type:'get',action:'getLevel'});
    this.getAll();
  },
};
</script>

<style lang="scss" scoped>
  .with-pre-select {
    .el-input-group__prepend {
      .el-select {
        width: 120px;
      }
    }
  }

  .money-range {
    .el-input {
      width: 100px;
    }
  }

</style>
